package com.example.treasure_back.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.treasure_back.enumerate.CommentType;
import com.example.treasure_back.mapper.TrashDataMapper;
import com.example.treasure_back.model.TrashDataModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TrashDataService {
    
    @Autowired
    private TrashDataMapper trashDataMapper;
    
    public void addTrashData(String image, String email, String accuracy, String category){
        TrashDataModel trashDataModel = new TrashDataModel();
        trashDataModel.setImage(image);
        trashDataModel.setEmail(email);
        trashDataModel.setAccuracy(accuracy);
        trashDataModel.setAccept(CommentType.NO_COMMENT);
        trashDataModel.setCategory(category);
        trashDataMapper.insert(trashDataModel);
    }

    public void commentResult(String image, CommentType accept){
        UpdateWrapper<TrashDataModel> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("image", image).set("accept", accept);
        trashDataMapper.update(new TrashDataModel(), updateWrapper);
    }

}
